#include <cstdio>
#include <cstring>
#include <memory.h>

int a[ 5 ], f[ 26 ], s[ 5 ], n, m;
char str[ 100 ];
bool ac, use[ 5 ];

void init( )
{
    int i, t = 0;
    for ( i = 1; i < n; i++ )
        scanf("%d", &a[ i ]);
    scanf("%d", &m);
    scanf("%s", str);
    for ( i = 0; i < strlen( str ); i++ )
        if ( str[ i ] >= 'a' && str[ i ] <= 'z' )
            f[ str[ i ] - 'a' ] = t++;
    ac = false;
    memset( use, 0, sizeof( use ) );
}

int calc( int &p )
{
    int i = p, l, r;
    if ( str[ i ] == '(' )
    {
        i++;
        l = calc( i );
    }
    else
        l = a[ s[ f[ str[ i ] - 'a' ] ] ];
    i++;
    if ( str[ i ] == '+' )
    {
        i++;
        if ( str[ i ] == '(' )
        {
            i++;
            r = calc( i );
        }
        else
            r = a[ s[ f[ str[ i ] - 'a' ] ] ];
        i++;
        p = i;
        return l + r;
    }
    else if ( str[ i ] == '-' )
    {
        i++;
        if ( str[ i ] == '(' )
        {
            i++;
            r = calc( i );
        }
        else
            r = a[ s[ f[ str[ i ] - 'a' ] ] ];
        i++;
        p = i;
        return l - r;
    }
    else if ( str[ i ] == '*' )
    {
        i++;
        if ( str[ i ] == '(' )
        {
            i++;
            r = calc( i );
        }
        else
            r = a[ s[ f[ str[ i ] - 'a' ] ] ];
        i++;
        p = i;
        return l * r;
    }
}

void dfs( int p )
{
    int i, dc = 1;
    if ( ac ) return ;
    if ( p < n )
    {
        for ( i = 0; i < n && !ac; i++ )
            if ( !use[ i ] )
            {
                s[ p ] = i;
                use[ i ] = true;
                dfs( p + 1 );
                use[ i ] = false;
            }
    }
    else
    {
        if ( calc( dc ) == m )
            ac = true;
    }
}

int main( )
{
    while ( scanf("%d%d", &n, &a[ 0 ]) )
    {
        if ( n == 0 && a[ 0 ] == 0 )
            break;
        init( );
        if ( strlen( str ) == 1 )
            if ( a[ 0 ] == m )
                puts("YES");
            else
                puts("NO");
        else
        {
            dfs( 0 );
            if ( ac )
                puts("YES");
            else
                puts("NO");
        }
    }
    return 0;
}
